package good

import (
	"api/internal/respons"
	"api/internal/svc"
	"api/internal/types"
	"context"
	"homepage_srv/homepageclient"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodRecommentLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGoodRecommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodRecommentLogic {
	return &GoodRecommentLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// 商品推荐
func (l *GoodRecommentLogic) GoodRecomment(req *types.GoodRecommentRequest) (resp *types.Response, err error) {
	goods, err := l.svcCtx.HomepageGrpc.GoodRecomment(l.ctx, &homepageclient.GoodRecommentRequest{
		CateId: req.CateId,
	})
	if err != nil {
		return respons.Error(400, "服务端错误", err.Error()), err
	}
	return respons.Success(goods), nil
}
